package com.zbzbzzz.qrcode.contorller;

import cn.hutool.extra.qrcode.QrCodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/")
public class IndexContorller {
    @GetMapping("genQRcode/{str}")
    public void genQRcode(HttpServletResponse response, @PathVariable("str")String str){
        try {
            QrCodeUtil.generate(str, 300,300,"png", response.getOutputStream());
            response.setContentType("image/png");
            response.flushBuffer();
        }
        catch (Exception e){
            e.printStackTrace();
        }

    }
}

